home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / interp / thread.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  3.0 KB  |  96 lines  |  [TEXT/ttxt]

  1. /**********************************************************************\
  2. *
  3. *  Copyright (c) 1994  Carnegie Mellon University
  4. *  All rights reserved.
  5. *  
  6. *  Use and copying of this software and preparation of derivative
  7. *  works based on this software are permitted, including commercial
  8. *  use, provided that the following conditions are observed:
  9. *  
  10. *  1. This copyright notice must be retained in full on any copies
  11. *     and on appropriate parts of any derivative works.
  12. *  2. Documentation (paper or online) accompanying any system that
  13. *     incorporates this software, or any part of it, must acknowledge
  14. *     the contribution of the Gwydion Project at Carnegie Mellon
  15. *     University.
  16. *  
  17. *  This software is made available "as is".  Neither the authors nor
  18. *  Carnegie Mellon University make any warranty about the software,
  19. *  its performance, or its conformity to any specification.
  20. *  
  21. *  Bug reports, questions, comments, and suggestions should be sent by
  22. *  E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  23. *
  24. ***********************************************************************
  25. *
  26. * $Header: thread.h,v 1.5 94/10/05 21:04:45 nkramer Exp $
  27. *
  28. \**********************************************************************/
  29.  
  30.  
  31. enum thread_status {
  32.     status_Running,
  33.     status_Suspended,
  34.     status_Debuggered,
  35.     status_Blocked,
  36.     status_Waiting,
  37.     status_Exited,
  38.     status_Killed
  39. };
  40.  
  41. struct thread_list {
  42.     struct thread *thread;
  43.     struct thread_list *next;
  44. };
  45.  
  46. struct thread_obj {
  47.     obj_t class;
  48.     struct thread *thread;
  49.     obj_t debug_name;
  50.     enum thread_status status;
  51. };
  52.  
  53. #define THREAD(o) obj_ptr(struct thread_obj *, o)
  54.  
  55. struct thread {
  56.     int id;
  57.     obj_t thread_obj;
  58.     struct thread *next, **prev;
  59.     void (*advance)(struct thread *thread);
  60.     enum thread_status status;
  61.     int suspend_count;
  62.     obj_t datum;
  63.     obj_t *stack_base, *stack_end;
  64.     obj_t *sp, *fp;
  65.     obj_t component;
  66.     unsigned pc;
  67.     obj_t cur_catch;
  68.     struct uwp *cur_uwp;
  69.     obj_t handlers;
  70. };
  71.  
  72. extern struct thread_list *all_threads(void);
  73. extern struct thread *thread_current(void);
  74. extern void thread_set_current(struct thread *thread);
  75. extern struct thread *thread_pick_next(void);
  76. extern struct thread *thread_create(obj_t debug_name);
  77. extern void thread_push_escape(struct thread *thread);
  78. extern void thread_pop_escape(struct thread *thread);
  79. extern void thread_kill(struct thread *thread);
  80. extern void thread_debuggered(struct thread *thread, obj_t condition);
  81. extern void thread_buggered(struct thread *thread);
  82. extern void thread_suspend(struct thread *thread);
  83. extern void thread_restart(struct thread *thread);
  84.  
  85. extern obj_t make_lock(void);
  86. extern boolean lock_query(obj_t lock);
  87. extern void lock_grab(struct thread *thread, obj_t lock,
  88.               void (*advance)(struct thread *thread));
  89. extern void lock_release(obj_t lock);
  90.  
  91. extern obj_t make_event(void);
  92. extern void event_wait(struct thread *thread, obj_t event, obj_t lock,
  93.                void (*advance)(struct thread *thread));
  94. extern obj_t event_signal(obj_t event);
  95. extern obj_t event_broadcast(obj_t event);
  96.